// 协议基类 所有协议都必须继承该类 并实现 onMessage onConnect onClose 方法
// Created by taojiaheng on 2020/6/1.
//

#ifndef WEBSOCKETSERVER_PROTOCOL_H
#define WEBSOCKETSERVER_PROTOCOL_H
#include "../../common/cdef.h"
class Connection;
class Protocol {
public:
    Protocol();
    ~Protocol();
    // 协议是否需握手
    bool is_handshake;
    // 检测分包位置
    virtual int input(BUFF * buff, Connection* client) = 0;
    // 协议解码
    virtual BUFF * decode(BUFF * _buff, Connection * client) = 0;
    // 协议编码
    virtual BUFF * encode(BUFF * _buff, Connection * client) = 0;
    // 处理协议握手函数
    virtual int handshake(BUFF * _buff, Connection * client) = 0;
};
#endif //WEBSOCKETSERVER_PROTOCOL_H
